package mytest;


/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/3/16 22:54
 * 实现 Runnable, 重写 run, 使用匿名内部类
 */
public class Thread04Demo {

    public static void main(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    System.out.println(Thread.currentThread().getName());
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        t.start();
    }
}
